import fetcher from "../apis/Fetcher";
import {Page, Pageable} from "../utils/Page";
import {NumberIdAndName} from "../types/BasicModels";

export interface QueryGoodsBrandGroupsRequest {
    name?: string
}

export function queryGoodsBrandGroups(queryGoodsBrandGroupsRequest: QueryGoodsBrandGroupsRequest, pageable: Pageable) {
    return fetcher.get<Page<QueryGoodsBrandGroupsResponse>>("/goodsBrandGroups", {...queryGoodsBrandGroupsRequest, ...pageable.toRequestParams()})
}

export interface QueryGoodsBrandGroupsResponse{
    id:number
    name:string
    brandAmount:number
}

export interface CreateGoodsBrandGroupRequest{
    name:string
}

export function createGoodsBrandGroup(createGoodsBrandGroupRequest:CreateGoodsBrandGroupRequest){
    return fetcher.post("goodsBrandGroups",{},createGoodsBrandGroupRequest)
}

export function updateGoodsBrandGroup(id:number,createGoodsBrandGroupRequest:CreateGoodsBrandGroupRequest){
    return fetcher.put(`goodsBrandGroups/${id}`,{},createGoodsBrandGroupRequest)
}

export function getAllGoodsBrandGroup(){
    return fetcher.get<Array<GoodsBrandGroupSummary>>("goodsBrandGroups")
}

export interface GoodsBrandGroupSummary{
    id:number
    name:string
    group?:NumberIdAndName
}